package com.hizt.consumer.controller;

import com.hzit.api.bean.Dept;
import com.hzit.api.client.DeptClientService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;

import javax.annotation.Resource;
import java.util.List;

@RestController
@RequestMapping("/consumer")
public class DeptConsumerController {

    @Resource
    private DeptClientService deptClientService;


    @GetMapping("/list")
    public List<Dept> list() {

        List<Dept> deptList = deptClientService.list();
        return deptList;
    }

    @GetMapping("/add")
    public boolean add(Dept dept) {

        //添加 请求方式:POST
        boolean add = deptClientService.add(dept);
        return add;
    }

    @GetMapping("/get/{deptno}")
    public Dept get(@PathVariable Integer deptno) {

        Dept dept = deptClientService.get(deptno);
        return dept;
    }




}
